#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include "module.h"
#include <stdint.h>
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
#include <sys/select.h>
#include "autoconfig.h"


#define AUDIO_RX_SERIAL_NUM	3
static int audio_fd = -1;

int audio_init(void *param)
{	
	int ret = -1;
	audio_fd = open("/dev/audio", O_RDWR | O_NONBLOCK);
	if (audio_fd < 0) return -1;

	if (param) {
		ret = ioctl(audio_fd, IOCTL_AUDIO_PARAM, (void *)param);
	}
	return ret;	
}

int audio_write(uint8_t *buf, uint32_t size)
{
	return write(audio_fd, buf, size);
}

int audio_read(uint8_t *buf, uint32_t size, uint32_t timeout)
{
	return serial_read(AUDIO_RX_SERIAL_NUM, buf, size, timeout);
}

